package com.getpebble.android.common.model;

import android.content.ContentValues;
import com.getpebble.android.common.core.trace.Trace;
import com.getpebble.android.util.JSONUtil;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class LanguagePackResponse {
    private static final String TAG = LanguagePackResponse.class.getSimpleName();
    @SerializedName("languages")
    public LanguagePack[] languagePacks;

    public static LanguagePackResponse from(String json) throws IllegalArgumentException {
        return (LanguagePackResponse) JSONUtil.marshall(json, LanguagePackResponse.class);
    }

    public List<ContentValues> toContentValues() {
        if (this.languagePacks == null) {
            return Collections.EMPTY_LIST;
        }
        List<ContentValues> contentValuesList = new ArrayList(this.languagePacks.length);
        for (LanguagePack languagePack : this.languagePacks) {
            if (languagePack.isValid()) {
                contentValuesList.add(languagePack.toContentValues());
            } else {
                Trace.warning(TAG, "Invalid language pack");
            }
        }
        return contentValuesList;
    }
}
